home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / timings.arc / REGCNV04.ASM next >
Assembly Source File  |  1986-01-18  |  2KB  |  93 lines

  1.     title    REGCNV04 -- Convert contents of AX to hex characters.
  2.     page    60,120
  3.  
  4.     name    REGCNV04    ; module
  5.  
  6. comment |         Module Specifications
  7.  
  8. Copyright: None.
  9.  
  10. Environment: IBM PC, tested under DOS 2.0.
  11.  
  12. Segmentation: Program segment CODE, public, byte aligned, class ''.
  13.  
  14. Public symbols and external references: See Symbols section of listing.
  15.  
  16. Link requirements: None, standalone subroutine.
  17.  
  18. Program derived from: None.
  19.  
  20. Original code by: Bob Smith and Tom Puckett, October 1983.
  21.  
  22. Modifications by: None.
  23.  
  24.  
  25.             Procedure Specifications
  26.  
  27. Public Procedure REGCNV04 -- Convert value in AX to ASCII characters.
  28.  
  29.     This is a subroutine to format and place in storage four ASCII
  30.     characters giving a hexadecimal representation of the value
  31.     passed in AX.
  32.  
  33.     Assumptions: None.
  34.  
  35.     Linkage: Near call and return.
  36.  
  37.     Arguments: AX contains value to be formatted.
  38.            ES:DI point to destination where result is to be placed.
  39.  
  40.     Effects: None.
  41.  
  42.     Results: Flags and AX destroyed.
  43.          DI incremented by four.
  44.          Four hexadecimal digits formatted as ASCII characters
  45.             placed at ES:DI.
  46.  
  47.     Return conditions: None.
  48.  
  49.     Limitations: None.
  50.  
  51. |
  52.     page
  53.  
  54. code    segment    public byte
  55.     assume    cs:code
  56.  
  57. hextable db    '0123456789ABCDEF'    ; for XLAT below
  58.  
  59.  
  60.  
  61.     public    REGCNV04
  62. REGCNV04    proc    near    ; see specifications at head of listing
  63.  
  64.     push    bx        ; preserve
  65.     push    dx
  66.  
  67.     cld            ; for STOSB below
  68.     mov    dx,ax        ; value to be formatted
  69.     mov    ah,4        ; four hex digits to convert
  70.     mov    bx,offset hextable    ; translate table
  71.  
  72. digitloop:
  73.     rol    dx,1        ; one bit at a time to minimize number of clocks
  74.     rol    dx,1
  75.     rol    dx,1
  76.     rol    dx,1
  77.     mov    al,dl
  78.     and    al,0fh        ; mask off what's not wanted
  79.     xlat    hextable    ; convert AL to ASCII
  80.     stosb            ; stuff AL at ES:DI, update DI
  81.     dec    ah        ; loop counter
  82.     jnz    digitloop
  83.  
  84.     pop    dx        ; restore
  85.     pop    bx
  86.     ret
  87.  
  88. REGCNV04 endp
  89.  
  90. code    ends        ; end code segment
  91.  
  92.      end        ; end module
  93.